package ar.com.solidussource.howmuchservices.backend.bo.impl;

import ar.com.solidussource.framework.backend.bo.exception.BusinessException;
import ar.com.solidussource.howmuchservices.backend.bo.AddressCRUDBO;
import ar.com.solidussource.howmuchservices.backend.bo.GeopointCRUDBO;
import ar.com.solidussource.howmuchservices.backend.bo.MarketBO;
import ar.com.solidussource.howmuchservices.backend.bo.MarketCRUDBO;
import ar.com.solidussource.howmuchservices.common.entities.Market;

public class MarketBOImpl implements MarketBO {
	
	private MarketCRUDBO marketCRUDBO;
	private AddressCRUDBO addressCRUDBO;
	private GeopointCRUDBO geopointCRUDBO;


	@Override
	public void createMarketFromScratch(Market market) throws BusinessException {		
		geopointCRUDBO.saveNew(market.getAddress().getGeopoint());
		addressCRUDBO.saveNew(market.getAddress());
		marketCRUDBO.saveNew(market);
		
	}
	
	@Override
	public void updateMarket(Market market) throws BusinessException {
		geopointCRUDBO.saveOrUpdate(market.getAddress().getGeopoint());
		addressCRUDBO.saveOrUpdate(market.getAddress());
		marketCRUDBO.saveOrUpdate(market);
		
	}	


	public MarketCRUDBO getMarketCRUDBO() {
		return marketCRUDBO;
	}


	public void setMarketCRUDBO(MarketCRUDBO marketCRUDBO) {
		this.marketCRUDBO = marketCRUDBO;
	}


	public AddressCRUDBO getAddressCRUDBO() {
		return addressCRUDBO;
	}


	public void setAddressCRUDBO(AddressCRUDBO addressCRUDBO) {
		this.addressCRUDBO = addressCRUDBO;
	}


	public GeopointCRUDBO getGeopointCRUDBO() {
		return geopointCRUDBO;
	}


	public void setGeopointCRUDBO(GeopointCRUDBO geopointCRUDBO) {
		this.geopointCRUDBO = geopointCRUDBO;
	}

}
